rm -rf build
mkdir build/

mkdir build/ejbjar
mkdir build/ejbjar/META-INF
if javac -classpath ".:${CLASSPATH}" -d build/ejbjar jhh09wxu/globalgadgets/ejb/entity/*.java jhh09wxu/globalgadgets/ejb/session/*.java; then
  true
else
  echo '*** compilation failed ***'
  exit 1
fi
cp persistence.xml build/ejbjar/META-INF
cd build/ejbjar
jar cvf ../globalgadgets.jar *
cd ../..

mkdir build/war
mkdir build/war/WEB-INF
mkdir build/war/WEB-INF/classes
if javac -classpath "./build/ejbjar:${CLASSPATH}" -d build/war/WEB-INF/classes jhh09wxu/globalgadgets/web/*.java ; then
  true
else
  echo '*** compilation failed ***'
  exit 1
fi
cp web.xml build/war/WEB-INF
cp -r jsps build/war
cd build/war
jar cvf ../globalgadgets.war *
cd ../..

cd build
# make sure that the enterprise application deployment directory has a
# unique name by including your groupxx or group name in the directory
# name (i.e. minimally replace "groupxx" with a suitable name of your own).
mkdir globalgadgets_jhh09wxu.ear
mkdir globalgadgets_jhh09wxu.ear/META-INF
cp globalgadgets.war globalgadgets.jar globalgadgets_jhh09wxu.ear
cp ../application.xml globalgadgets_jhh09wxu.ear/META-INF
cd ..

# the command to undeploy an existing globalgadgets deployment on cmpvstuweb-02
# would be:
# rm -rf ~/web/globalgadgets_groupxx.ear
# the command to deploy this app on cmpvstuweb-02 is
# cp -r build/globalgadgets_groupxx.ear ~/web/
